<?php

namespace App\Model;

use App\User;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Model\UserBonusCount
 *
 * @property int $id
 * @property int|null $type 1：会员分销提成，2：一元拉新
 * @property int|null $income_type 类型:1收入，0支出
 * @property int $user_id 会员id
 * @property float|null $money 收入的金额
 * @property int $relation_id 关联表id，比如类型是1的会员分销提成关联表是user_commission_details返佣表
 * @property string|null $describe 描述
 * @property \Illuminate\Support\Carbon|null $created_at 创建时间
 * @property \Illuminate\Support\Carbon|null $updated_at 修改时间
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount whereDescribe($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount whereIncomeType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount whereMoney($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount whereRelationId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount whereUserId($value)
 * @mixin \Eloquent
 * @property-read \App\User $user
 * @property-read \App\Model\UserInviteOneYuan $userInviteOnYuan
 * @property int|null $relation_user_id 被邀请的用户id
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\UserBonusCount whereRelationUserId($value)
 */
class UserBonusCount extends Model
{
    protected  $table = 'user_bonus_count';

    /**
     * 会员一元拉新记录
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function userInviteOnYuan()
    {
        return $this->hasOne(UserInviteOneYuan::class,"relation_user_id","id");
    }

    /**
     * 会员奖励金记总录表属于哪个会员
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(User::class, "user_id", "id");
    }

}
